package com.client1.web;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
public class TestClientController {
    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping("test02")
    @HystrixCommand(fallbackMethod = "test03")
    public String test02(){
        String forObject = restTemplate.getForObject("http://SERVER/test01", String.class);
        /*if(forObject!=null){
            throw new RuntimeException("=====================");
        }*/
        return forObject;
    }
    public String test03(){
        return "调用错误";
    }

}
